﻿using RayDen.Library.Entity.Interface;

namespace RayDen.Library.Entity.Renderer
{
    public class OutputSettingsInfo : RendererSettingsBase, IRendererOutputSettings
    {

        public const string OSImageWidth = "ImageWidth";
        public const string OSImageHeight = "ImageHeight";
        public const string OSBitsPerPixel = "BitsPerPixel";
        public const string OSGammaCorrection = "GammaCorrection";
        public const string OSToneMap = "ToneMap";
        public const string OSToneMapValue = "ToneMapValue";
        public const string OSFilePath = "FilePath";


        public int Width
        {
            get
            {
                return (int)this[OSImageWidth];
            }
            set
            {
                this[OSImageWidth] = value;
            }
        }
        public int Height
        {
            get
            {
                return (int)this[OSImageHeight];
            }
            set
            {
                this[OSImageHeight] = value;
            }
        }
        public int BitsPerPixel { get; set; }
        public bool GammaCorrection
        {
            get
            {
                return (bool)this[OSGammaCorrection];
            }
            set
            {
                this[OSGammaCorrection] = value;
            }
        }
        public bool ToneMap
        {
            get
            {
                return (bool)this[OSToneMap];
            }
            set
            {
                this[OSToneMap] = value;
            }
        }
        public float ToneMapValue
        {
            get
            {
                return (float)this[OSToneMapValue];
            }
            set
            {
                this[OSToneMapValue] = value;
            }
        }
        public bool Save { get; set; }
        public string FilePath
        {
            get
            {
                return (string)this[OSFilePath];
            }
            set
            {
                this[OSFilePath] = value;
            }
        }


        public OutputSettingsInfo() { }

        public OutputSettingsInfo(IParameterBag cfg)
            : base(cfg)
        {
            this.Width = cfg.Get(OSImageWidth, 512);
            this.Height = cfg.Get(OSImageHeight, 384);
            this.BitsPerPixel = cfg.Get(OSBitsPerPixel, 24);
            this.GammaCorrection = cfg.Get(OSGammaCorrection, false);
            this.ToneMap = cfg.Get(OSToneMap, false);
            this.ToneMapValue = cfg.Get(OSToneMapValue, 1.0f);
            this.FilePath = cfg.Get(OSFilePath, string.Empty);
            this.Save = !string.IsNullOrWhiteSpace(this.FilePath);
        }
    }
}